#!/bin/sh /etc/rc.common

##########################################################################
#
# Copyright 2016 Sierra Wireless
#
# Copyright (C) 2020, Tano Systems LLC. All rights reserved.
# Anton Kikin <a.kikin@tano-systems.com>
#
##########################################################################

#
# Script to load modem image
# load modem image once modem partition is mounted
#

START=17

start() {
	search_dir="/sys/bus/msm_subsys/devices/"
	for entry in `ls $search_dir`
	do
		subsys_temp=`cat $search_dir/$entry/name`
		if [ "$subsys_temp" = "modem" ]
		then
			if [ -w $search_dir/$entry/firmware_load ]; then
				# Send '1' to firmware_load to trigger Kernel load modem
				# image to Q6. The whole operation will take about 6s,
				# running in background so that it will not block the
				# following startup scripts.
				echo 1 > $search_dir/$entry/firmware_load &
			fi
		fi
	done

	return 0
}

stop() {
	# Currently Kernel doesn't support to stop modem.
	# Keep placeholder so it can extend in the future.
	return 0
}
